<?php
	include_once "include/Functions.php";
	
	$exercise_id= $_GET['exercise_id'];
	
	$person_id = $_SESSION['user_id'];
	$sql = "SELECT  *
				FROM `data_exerc` 
				WHERE id_exerc = $exercise_id;";
	//echo $sql;

	$mat = Functions::getDataSql($sql);
	$cont= count($mat);
	
	$table = "";
	for( $i=0; $i < $cont; $i++ ) {
		//$time = Functions::convertMiliToTime($mat[$i]['d_time']);
		//$speed = number_format($mat[$i]['speed'] * 3.6, 2);
		$table.= "<tr>
                    <td>{$mat[$i]['id']}</td>
                    <td>{$mat[$i]['d_time']}</td>
                    <td>{$mat[$i]['lat']}</td>
                    <td>{$mat[$i]['lon']}</td>
                    <td>{$mat[$i]['alt']}</td>
                    <td>{$mat[$i]['hrm']}</td>
                    <td>{$mat[$i]['speed']}</td>
                    <td>{$mat[$i]['accuracy']}</td>
                 </tr>";
	}


	/*$equals = "";
	for($i=0; $i < $cont-1; $i++){
		$j= $i+1;
		for(; $j < $cont; $j++ ){
			if( ($mat[$i]['lat'] == $mat[$j]['lat']) && ($mat[$i]['lon'] == $mat[$j]['lon'])){
				$equals.= "<tr>
							<td>{$i}</td>
							<td>{$mat[$i]['id']}</td>
							<td>{$mat[$i]['d_time']}</td>
							<td>{$mat[$i]['lat']}</td>
							<td>{$mat[$i]['lon']}</td>
							<td>{$mat[$i]['alt']}</td>
							<td>{$mat[$i]['hrm']}</td>
							<td>{$mat[$i]['heading']}</td>
							<td>{$mat[$i]['speed']}</td>
							<td>{$mat[$i]['accuracy']}</td>
							<td>{$j}</td>
						 </tr>";
			}
		}
	}*/
?>

<div id="page-wrapper">
	<div class="row">
		<div class="col-lg-12">
			<div class="panel panel-default">
				<div class="panel-heading">
					Estatisticas
				</div>
				<div class="panel-body">
					<div class="table-responsive">
						<table class="table">
							<thead>
								<tr>
									<th>ID</th>
									<th>Time</th>
									<th>Lat</th>
									<th>Lon</th>
									<th>Alt</th>
                           <th>HRM</th>
									<th>Speed</th>
									<th>Accuracy</th>                                  
								</tr>
							</thead>
							<tbody>
								<?php echo $table; ?>
							</tbody>
						</table>
					</div>                        
				</div>
			</div>
		</div>
	</div>

	<div class="row">
<!-- /.col-lg-6 -->
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            Iguais
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table class="table">
                                    <thead>
                                        <tr>
											<th>i - j</th>
                                            <th>ID</th>
                                            <th>Time</th>
                                            <th>Lat</th>
                                            <th>Lon</th>
                                            <th>Alt</th>
                                            <th>HRM</th>
                                            <th>Speed</th>
                                            <th>Accuracy</th>                                  
											<th>Equal to</th>
                                        </tr>
                                    </thead>
                                    <tbody>
										<?php// echo $equals; ?>
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.table-responsive -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-6 -->	
	</div>
</div>
<!-- /#wrapper -->